public class ServiceCollection extends Collection {

	public String accept { get; set; }
	public Map<String, String> categoriesMap { get; set; }
	public String repliesLink { get; set; } 
	
	public ServiceCollection(String title) {
		super(title);
	}

	public ServiceCollection(XmlStreamReader reader) {
		categories = new List<Categories>();
		String tagName = 'collection';
		handleAttributes(reader, tagName);
        if (reader.hasNext()) {
			reader.next();
			while (reader.hasNext()) { 
				if (reader.getEventType() == XmlTag.END_ELEMENT) {
					if (reader.getLocalName() == 'collection') {
						return;
					} 
				} else if (reader.getEventType() == XmlTag.CHARACTERS) {
                	if ( ! reader.isWhitespace()) { 
                		if (tagName == 'title') {
                			setTitle(reader.getText());
                		}
                	}
            	} else if (reader.getEventType() == XmlTag.START_ELEMENT) { 
					tagName = reader.getLocalName(); 
					handleAttributes(reader, tagName);
					if (tagName == 'categories') {
						categories.add(new Categories(reader));
					} 
            	}
               	reader.next(); 
			}
        }
	}
	 
	private void handleAttributes(XmlStreamReader reader, String tagName) {
		for (integer i=0; i<reader.getAttributeCount(); i++) {
       		String name = reader.getAttributeLocalName(i);
       		String value = reader.getAttributeValueAt(i);
        	if (tagName == 'collection') {
        		if (name == 'href') {
        			href = value;
        		} 
        	}
        }
	}
	
}